package com.ruoyi.sys.tclassify.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sys.tclassify.domain.TClassify;
import com.ruoyi.sys.tclassify.service.ITClassifyService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 分类信息管理Controller
 * 
 * @author hyl
 * @date 2025-06-08
 */
@RestController
@RequestMapping("/tclassify/tclassify")
public class TClassifyController extends BaseController
{
    @Autowired
    private ITClassifyService tClassifyService;

    /**
     * 查询分类信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('tclassify:tclassify:list')")
    @GetMapping("/list")
    public AjaxResult list(TClassify tClassify)
    {
        List<TClassify> list = tClassifyService.selectTClassifyList(tClassify);
        return success(list);
    }

    /**
     * 导出分类信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('tclassify:tclassify:export')")
    @Log(title = "分类信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TClassify tClassify)
    {
        List<TClassify> list = tClassifyService.selectTClassifyList(tClassify);
        ExcelUtil<TClassify> util = new ExcelUtil<TClassify>(TClassify.class);
        util.exportExcel(response, list, "分类信息管理数据");
    }

    /**
     * 获取分类信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('tclassify:tclassify:query')")
    @GetMapping(value = "/{classId}")
    public AjaxResult getInfo(@PathVariable("classId") Long classId)
    {
        return success(tClassifyService.selectTClassifyByClassId(classId));
    }

    /**
     * 新增分类信息管理
     */
    @PreAuthorize("@ss.hasPermi('tclassify:tclassify:add')")
    @Log(title = "分类信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TClassify tClassify)
    {
        return toAjax(tClassifyService.insertTClassify(tClassify));
    }

    /**
     * 修改分类信息管理
     */
    @PreAuthorize("@ss.hasPermi('tclassify:tclassify:edit')")
    @Log(title = "分类信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TClassify tClassify)
    {
        return toAjax(tClassifyService.updateTClassify(tClassify));
    }

    /**
     * 删除分类信息管理
     */
    @PreAuthorize("@ss.hasPermi('tclassify:tclassify:remove')")
    @Log(title = "分类信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classIds}")
    public AjaxResult remove(@PathVariable Long[] classIds)
    {
        return toAjax(tClassifyService.deleteTClassifyByClassIds(classIds));
    }
}
